<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>事件绑定</title>
    <script src="./js/vue.js"></script>
</head>
<body>
    <div id="app"> 
        {{message}}
        <h2>count:{{count}}</h2>
        <button v-on:click="changCount1">点击count++</button>
        <button @click="chagecount2">点击count--</button>
    </div>
</body>
</html>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            message: '事件绑定',
            count: 0
        },
        methods:{
            //点击count--
            chagecount2:function(){
                if(this.count>0){
                    this.count--
                }else{
                    alert('不能再减了')
                    this.count = 0
                }
                
            },
            //点击count++
            changCount1(){
               //this:当前vue实例
                this.count++
            }
        }
    })
</script>